from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC



class Base:
    def __init__(self):
        cap={
            "platformName": "Android",
            "deviceName": "emulator-5554",
            "automationName": "uiautomator2",
            "appPackage": "com.kongfz.app",
            "appActivity": ".home.mvvm.homepage.HomeActivity",
            "noReset": True
        }
        self.driver=webdriver.Remote('http://127.0.0.1:4723/wd/hub',cap)
        self.driver.implicitly_wait(10)
    def find_ele(self,ele):
        loc=self.driver.find_element(*ele)
        return loc
    def find_huadong(self,a,b,c,d):
        self.driver.swipe(a,b,c,d,200)
    def find_qingqiao(self,a,b):
        self.driver.tap([(a,b)],200)
    def find_jietu(self,filename):
        self.driver.save_screenshot(filename)
    def find_tuichu(self):
        self.driver.quit()
    def find_fanhui(self):
        self.driver.press_keycode(3)
    def find_xianshi(self,ele):
        loc=WebDriverWait(self.driver,10).until(EC.element_to_be_clickable(ele))
        return loc